package com.micangcaihang.common.http;


import com.micangcaihang.common.http.exception.ApiException;

import io.reactivex.observers.DisposableObserver;

/**
 * @Description: API统一订阅者
 */
abstract class ApiSubscriber<T> extends DisposableObserver<T> {

    ApiSubscriber() {

    }

    @Override
    public void onError(Throwable e) {
        e.printStackTrace();
        if (e instanceof ApiException) {
            onError((ApiException) e);
        } else {
            onError(ApiException.handleException(e));
        }
    }

    protected abstract void onError(ApiException e);
}
